/*
 * show_mainwindow.h
 *
 *  Created on: Apr 30, 2011
 *      Author: tqlong
 */

#ifndef SHOW_MAINWINDOW_H_
#define SHOW_MAINWINDOW_H_
#include <QtGui/QMainWindow>

class DrawArea;
class Viewer;
class Axis;
class QLineEdit;
class QToolBar;
class QAction;

class MainWindow :  public QMainWindow
{
  Q_OBJECT
protected:
  Viewer* m_viewer;
  DrawArea *m_drawArea;
  QLineEdit *m_edtXMIN, *m_edtXMAX, *m_edtYMIN, *m_edtYMAX;
  QToolBar *m_tbTools;
  QAction *m_actRefresh;
public slots:
  void slot_refresh();
public:
  MainWindow(Viewer* viewer, QWidget* parent = 0);
  void plot(QWidget* drawArea);
  void prepareAxis(Axis& axis);
};

class DrawArea : public QWidget
{
  MainWindow* m_mainWindow;
  QPointF m_currentPoint;
public:
  DrawArea(MainWindow* mainWindow, QWidget* parent = 0) : QWidget(parent), m_mainWindow(mainWindow), m_currentPoint(0, 0) {}
  void paintEvent (QPaintEvent *e) { m_mainWindow->plot(this); }
  const QPointF& currentPoint() const { return m_currentPoint; }
  void set_currentPoint(const QPointF& currentPoint) { m_currentPoint = currentPoint; }
};

#endif /* SHOW_MAINWINDOW_H_ */
